package com.aj.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class UpdatePassword extends BaseActivity {
	private Button ok;
	private EditText password_enter;
	private EditText repassword_enter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_set_password);
		initView();
	}

	private void initView() {
		ok = (Button) findViewById(R.id.ok);
		password_enter = (EditText) findViewById(R.id.password_enter);
		repassword_enter = (EditText) findViewById(R.id.repassword_enter);
		setActionBarTitle(R.string.setpassword_title_text);
		ClickEvent clickEvent = new ClickEvent();
		ok.setOnClickListener(clickEvent);
	}

	class ClickEvent implements OnClickListener {
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.ok:
				if (password_enter.getText().toString().trim().length() == 0) {
					Toast.makeText(UpdatePassword.this,
							getString(R.string.enter_password_hinttext),
							Toast.LENGTH_LONG).show();
					return;
				}
				if (repassword_enter.getText().toString().trim().length() == 0) {
					Toast.makeText(UpdatePassword.this,
							getString(R.string.enter_sure_password_hinttext),
							Toast.LENGTH_LONG).show();
					return;
				}
				if (!repassword_enter.getText().toString().trim()
						.equals(password_enter.getText().toString().trim())) {
					Toast.makeText(UpdatePassword.this,
							getString(R.string.double_sure_password_hinttext),
							Toast.LENGTH_LONG).show();
					return;
				}
				finish();
				break;
			default:
				break;
			}
		}
	}
}
